
key = ""
function PrintTable(table , level)
  level = level or 1
  local indent = ""
  for i = 1, level do
    indent = indent.."  "
  end

  if key ~= "" then
    print(indent..key.." ".."=".." ".."{")
  else
    print(indent .. "{")
  end

  key = ""
  for k,v in pairs(table) do
     if type(v) == "table" then
        key = k
        PrintTable(v, level + 1)
     else
        local content = string.format("%s%s = %s", indent .. "  ",tostring(k), tostring(v))
      print(content)  
      end
  end
  print(indent .. "}")

end

--定义
local a = { 1, 2, 3, 4}
--下标访问
print(a[1], a[2], a[3], a[4])
--删除一个元素
table.remove (a , 3)
PrintTable(a)
--添加一个元素

table.insert (a, 3 ,3)
PrintTable(a)
--打印长度
print("Test1 " .. table.getn(a))
--合并
b={5,6,7,8}
for k,v in pairs(b) do  
    table.insert (a,table.getn(a)+1, v)
    a[k] = v
end
PrintTable(a,14)
